<template>
  <div class="home">
    <header></header>
    <div class="homepage">
      <div class="hom_back">
        <img src="../../../static/image/head.png" />
        <span class="goout" @click="goout">
          <img
            src="../../../static/image/goout.png"
            alt
            style="   margin-right: 0.05rem;width: 0.26rem;height: 0.26rem;margin-top: 0.05rem;"
          />
          退出登录
        </span>
        <div v-for="(item, index) in arr" :key="index">
          <div class="nav" @click="goOrder">
            <div class="nav_oitem">
              <span style="margin-left:0.30rem;font-size:0.32rem;color:#212C67;"
                >业务总览</span
              >
              <div class="nav_item" style="font-size:0.24rem;">
                <span>总盈利</span>
                <span>昨日盈利</span>
              </div>
            </div>
            <div class="nav_item1">
              <div>￥{{ item.grossIncome / 100 }}</div>
              <div
                style="height:0.80rem;width:0.005rem;border-left:0.005rem solid #ccc;margin-top: 0.20rem;"
              ></div>
              <div>+{{ item.yesterdayIncome / 100 }}</div>
            </div>
          </div>
        </div>
      </div>
      <div class="total" v-for="(item, index) in arr" :key="index">
        <div class="total_item">
          <span>用户总数</span>
          <div>{{ item.userCount }}</div>
        </div>
        <div class="total_item">
          <span>付费用户总数</span>
          <div>{{ item.paymentUserCount }}</div>
        </div>
      </div>
      <div class="ranking">
        <span style="margin-left:0.45rem;">授课总排名</span>
        <div>
          <div class="ran_oitem" v-for="(item, index) in rankList" :key="index">
            <span
              style="margin-left:0.32rem;width:3.58rem;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;"
              >{{ item.name }}</span
            >
            <span style="margin-right:0.53rem;color:#666666;"
              >{{ item.buyNum }}人开通</span
            >
          </div>
        </div>
      </div>
      <div class="ranking" v-show="nothing" style="margin-bottom:2rem;">
        <img src="../../../static/image/nothing.png" alt />
        <div class="ranking_zi">没有更多数据</div>
      </div>
    </div>
    <footer>
      <Footers></Footers>
    </footer>
  </div>
</template>
<script>
import axios from "axios";
import Footers from "../footer";
import { Toast } from "mint-ui";
import { ofheadquarters } from "../../api/api.js";

export default {
  name: "HelloWorld",
  components: {
    Footers
  },
  data() {
    return {
      arr: [],
      rankList: [],
      nothing: false
    };
  },
  methods: {
    goOrder() {
      this.$router.push({ path: "/Generalhospital/Orderdetails" });
    },
    Generahompage() {
      let that = this;
      that.bus.$emit("loading", true); //开始
      let params = {};
      let a = localStorage.getItem("token");
      a = JSON.parse(a);
      console.log(a);
      ofheadquarters(params, a).then(res => {
        if (res.data.code == 0) {
          Toast(res.data.message);
        } else {
          let Arr = res.data.data;
          that.arr.push(Arr);
          (that.arr = that.arr), (that.rankList = res.data.data.rankList);
          console.log(that.rankList);
          if (that.rankList.lenght == 0) {
            this.nothing = true;
          } else {
            this.nothing = false;
          }
        }
        that.bus.$emit("loading", false); //结束
      });
      // that.bus.$emit('loading', false);//结束
    },
    //退出登录
    goout() {
      localStorage.clear();
      this.$router.push({ path: "/" });
    }
  },
  mounted() {
    this.Generahompage();
  }
};
</script>
<style lang="scss" scoped>
.home {
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 1.5rem;
}
.homepage {
  width: 100%;
  height: auto;
  background: #f8f9fc;
  flex: 1;
}

.hom_back {
  width: 100%;
  height: 4.5rem;
  position: relative;
}

.hom_back img {
  width: 100%;
  height: 100%;
  position: relative;
}
.goout {
  position: absolute;
  font-size: 0.25rem;
  color: #cfcfcf;
  top: 0.6rem;
  z-index: 999;
  left: 0.4rem;
  display: flex;
}
.nav {
  width: 6.94rem;
  height: auto;
  margin: auto;
  border-radius: 0.2rem 0.2rem 0.2rem 0.2rem;
  position: absolute;
  top: 1.74rem;
  left: 0.28rem;
  box-shadow: 0 0.04rem 0.68rem 0 rgba(39, 52, 125, 0.25);
}
.nav_oitem {
  background: #fff;
  height: 1.65rem;
  border-radius: 0.2rem 0.2rem 0.2rem 0;
  // padding-top:0.46rem;
  box-sizing: border-box;
}
.nav_item {
  display: flex;
  justify-content: space-between;
  margin: 0.3rem 0.3rem 0 0.4rem;
}

.nav_item1 {
  display: flex;
  justify-content: space-between;
  height: 1.16rem;
  background: #e8ebf5;
  border-radius: 0 0 0.2rem 0.2rem;
  line-height: 1rem;
  padding: 0 0.2rem 0 0.2rem;
  font-size: 0.42rem;
}

.nav_item1 div:nth-of-type(1) {
  width: 1.12rem;
  text-align: center;
  /* overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap; */
}

.nav_item1 div:nth-last-of-type(1) {
  width: 1.12rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.total {
  width: 100%;
  /* border:1rpx solid black; */
  height: 2rem;
  margin: auto;
  margin-top: 0.3rem;
  display: flex;
  justify-content: space-around;
  box-sizing: border-box;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

.total_item {
  width: 3.42rem;
  height: 1.78rem;
  /* border: 1rpx solid black; */
  text-align: center;
  background: #fff;
  box-sizing: border-box;
  // padding-top: 0.21rem;
  box-shadow: 0 0.04rem 0.68rem 0 rgba(39, 52, 125, 0.25);
  border-radius: 0.08rem 0.08rem 0.08rem 0.08rem;
}

.total_item span {
  font-size: 0.24rem;
  /* margin-top: 30rpx; */
}

.total_item div {
  color: #ffb400;
  font-size: 0.42rem;
  // margin-top: 0.25rem;
}

.ranking {
  width: 100%;
  height: auto;
  margin-top: 0.58rem;
  font-size: 0.32rem;
  img {
    margin: auto;
    width: 3.06rem;
    height: 2rem;
    margin-top: 1.8rem;
  }
}
.ranking_zi {
  text-align: center;
  margin-top: 0.1rem;
  font-size: 0.28rem;
}
.ran_oitem {
  width: 6.84rem;
  margin: auto;
  border: 0.02rem solid #cfcfcf;
  height: 1.1rem;
  line-height: 1.1rem;
  display: flex;
  justify-content: space-between;
  margin-top: 0.3rem;
  font-size: 0.26rem;
  box-shadow: 0 0.04rem 0.28rem 0 rgba(39, 52, 125, 0.05);
  border-radius: 0.32rem 0.32rem 0.32rem 0.32rem;
}
</style>